package com.sjl.crowd.controller;

import com.sjl.crowd.domain.Admin;
import com.sjl.crowd.service.AdminService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @Author ShiJieLin
 * @Date 2021/12/18 20:03
 * @Version 1.0
 */
@Controller
@RequestMapping("/admin")
public class AdminController {

    private final AdminService adminService;

    public AdminController(AdminService adminService) {
        this.adminService = adminService;
    }

    @RequestMapping("/list")
    public ModelAndView listAdmin(){
        ModelAndView mv = new ModelAndView();
        List<Admin> listAdmin = adminService.listAll();
        mv.setViewName("views/list");
        mv.addObject("listAdmin", listAdmin);
        return mv;
    }

}
